-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Allow to specify pre-allocated buffer in audicore.WaveFile #2032
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
It lets us re-use the same buffer for playing multiple files. This also allows us to control the size of the buffer. Half of the buffer will be used for the fist, and half for the second internal buffer.
|
Good idea! A few thoughts pre-review:
|
|
Good point about documenting the default size, I will add that. I went for a single buffer mostly because it simplifies the usage, and lets us skip explaining what double buffering is. I'm not worried about memory fragmentation, because it's going to be allocated at the beginning of your program anyways. By the way, experiments show that a much smaller buffer than 512 seems to be working just fine, so we might want to reconsider the default. |
|
I suppose the optimal buffer size depends on the bit rate. |
And speed of processor, and what other background tasks are happening, so it's probably hard to specify without experimentation. |
|
All the better to have it user-controlled. |
jepler
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks fine, I didn't spot any problems.
As we discussed on discord, I hope that in the future we can revisit this and reduce runtime memory allocations further (and maybe reduce memory allocated overall) by putting the AudioOut object in the driver's seat. But that work's not started, and this presents a solid improvement right now.
|
@dhalbert Please merge if you don't want to review. |
|
I actually just realized that I didn't add the information about default buffer size to the documentation. I will do that tomorrow. |
This also allows us to control the size of the buffer. Half of the
buffer will be used for the fist, and half for the second internal
buffer.